const RETime = {
  // 日期
  date: () => {
    let pattern = String.raw`^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$`;
    let msg = '日期格式yyyy-mm-dd错误';
    return {
      reg: new RegExp(pattern, ''),
      msg,
    };
  },
  // 时间
  time: () => {
    let pattern = String.raw`^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$`;
    let msg = '时间格式hh:ii:ss错误';
    return {
      reg: new RegExp(pattern, ''),
      msg,
    };
  },
  // 日期时间
  datetime: () => {
    let pattern = String.raw`^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29) ([01]d|2[0-3]):[0-5]d:[0-5]d$`;
    let msg = '日期时间格式yyyy-mm-dd hh:ii:ss错误';
    return {
      reg: new RegExp(pattern, 'i'),
      msg,
    };
  },
};

export default RETime;
